﻿<UserControl x:Class="Kaskelot.SP.UI.Analys.Controls.TreeContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="600" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:pims="clr-namespace:Kaskelot.SP.UI.Analys.Converters">
    <UserControl.Resources>
        <!--<pims:BoolToVisibilityConverter x:Key="BoolConverter" />-->
        
        <telerik:ContainerBindingCollection x:Name="EntityTreeBindings">
            <telerik:ContainerBinding PropertyName="IsChecked" Binding="{Binding Checked, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsExpanded" Binding="{Binding Expanded, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled, Mode=TwoWay}"/>
        </telerik:ContainerBindingCollection>

        <telerik:ContainerBindingCollection x:Name="FieldTreeBindings">
            <telerik:ContainerBinding PropertyName="IsChecked" Binding="{Binding Checked, Mode=TwoWay}" />
        </telerik:ContainerBindingCollection>

        <telerik:HierarchicalDataTemplate x:Key="Field" telerik:ContainerBinding.ContainerBindings="{StaticResource FieldTreeBindings}">
            <TextBlock Text="{Binding NameInQueryBuilder}"></TextBlock>
        </telerik:HierarchicalDataTemplate>

        <telerik:HierarchicalDataTemplate x:Key="Entity" ItemsSource="{Binding Fields}" ItemTemplate="{StaticResource Field}" telerik:ContainerBinding.ContainerBindings="{StaticResource EntityTreeBindings}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" />
                <!--<Image Source="/Kaskelot.SP.UI.Analys;component/Images/check_sort_by_green_16x16.png" 
                       Visibility="{Binding IsKeyEntity, Converter={StaticResource BoolConverter}}"  
                       Margin="5,0,0,0" />-->
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <telerik:RadPaneGroup Margin="10" HorizontalAlignment="Left" Name="PaneGroup" telerik:StyleManager.Theme="Summer" Width="480" Height="300">
            <telerik:RadPane Name="ProjectPane" Title="1. Select entities and fields in pims" CanUserClose="False" CanFloat="False" CanUserPin="False" CanDockInDocumentHost="False" ContextMenuTemplate="{x:Null}">
                <telerik:RadPane.Content>
                    <ScrollViewer>
                        <telerik:RadTreeView HorizontalAlignment="Left" Name="EntityTree" VerticalAlignment="Top" telerik:StyleManager.Theme="Summer" 
                                 ItemTemplate="{StaticResource Entity}" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" Checked="EntityTree_Checked" Unchecked="EntityTree_Unchecked" Padding="10,0,0,0">
                            <!--<telerik:RadContextMenu.ContextMenu>
                                <telerik:RadContextMenu x:Name="EntityContextMenu" Opened="EntityContextMenu_Opened">
                                    <telerik:RadMenuItem Header="Set as key" Click="RadMenuItem_Click" />
                                </telerik:RadContextMenu>
                            </telerik:RadContextMenu.ContextMenu>-->
                        </telerik:RadTreeView>
                    </ScrollViewer>
                </telerik:RadPane.Content>
            </telerik:RadPane>
        </telerik:RadPaneGroup>
    </Grid>
</UserControl>